Skip to content

Commit e3ec2ad

Browse files
committed
[fix] stop duplicating encryption on handle
1 parent 238ec00 commit e3ec2ad

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

Example/Paystack iOS Example/ViewController.swift

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,19 @@ class ViewController: UIViewController, PSTCKPaymentCardTextFieldDelegate {
131131

132132
let transactionParams = PSTCKTransactionParams.init();
133133
// charging 75naira, 80kobo
134-
transactionParams.amount = 244;
134+
transactionParams.amount = 7580;
135135

136136
do {
137-
try transactionParams.setMetadataValue("iOS SDK", forKey: "custom_fields");
138-
try transactionParams.setCustomFieldValue("iOS SDK", displayedAs: "Another");
139-
try transactionParams.setCustomFieldValue("Emi ni", displayedAs: "One else");
137+
try transactionParams.setCustomFieldValue("iOS SDK", displayedAs: "Paid Via");
138+
try transactionParams.setCustomFieldValue("Paystack hats", displayedAs: "To Buy");
140139
try transactionParams.setMetadataValue("iOS SDK", forKey: "paid_via");
141140
} catch {
142141
print(error);
143142
}
144143

145-
transactionParams.email = "ibrahim@paystack.com";
144+
// set an email
145+
transactionParams.email = "";
146146

147-
print(transactionParams.description);
148-
149147
// transactionParams.subaccount = "ACCT_80d907euhish8d";
150148
// transactionParams.bearer = "subaccount";
151149
// transactionParams.transaction_charge = 280;
@@ -162,10 +160,10 @@ class ViewController: UIViewController, PSTCKPaymentCardTextFieldDelegate {
162160
}
163161
self.chargeCardButton.isEnabled = true;
164162
}, didRequestValidation: { (reference) -> Void in
165-
self.tokenLabel.text = reference + " requested validation"
163+
self.tokenLabel.text = "requested validation: " + reference
166164
self.tokenLabel.isHidden = false
167165
}, didTransactionSuccess: { (reference) -> Void in
168-
self.tokenLabel.text = reference
166+
self.tokenLabel.text = "succeeded: " + reference
169167
self.tokenLabel.isHidden = false
170168
self.chargeCardButton.isEnabled = true;
171169
})
@@ -194,7 +192,7 @@ class ViewController: UIViewController, PSTCKPaymentCardTextFieldDelegate {
194192
if successfulResponse && error == nil && data != nil{
195193
// All was well
196194
let newStr = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
197-
print(newStr)
195+
print(newStr ?? "<Unable to read response>")
198196
} else {
199197
if let e=error {
200198
print(e.localizedDescription)

Paystack/PSTCKAPIClient.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ - (void) makeChargeRequest:(NSData *)data
272272
return;
273273
} else {
274274
// This is where we test the status of the request.
275-
if([[responseObject status] isEqual:@"1"] || [[responseObject status] isEqual:@"success"]){
275+
if([[responseObject status] isEqual:@"1"] ){
276+
[self.operationQueue addOperationWithBlock:^{
277+
successCompletion(responseObject.reference);
278+
}];
279+
} else if([[responseObject status] isEqual:@"success"]){
276280
[self.operationQueue addOperationWithBlock:^{
277281
successCompletion(responseObject.reference);
278282
}];
@@ -295,7 +299,6 @@ - (void) makeChargeRequest:(NSData *)data
295299
[self didEndWithErrorMessage:@"Invalid PIN provided. Expected exactly 4 digits." completion:errorCompletion];
296300
return;
297301
}
298-
handle = [PSTCKRSA encryptRSA:handle];
299302
NSData *hdata = [PSTCKFormEncoder formEncryptedDataForCard:card
300303
andTransaction:transaction
301304
andHandle:[PSTCKRSA encryptRSA:handle]

0 commit comments

Comments
 (0)